//
//  HomeMoreTable.m
//  GoldOperationClient
//
//  Created by yaxue wang on 16/11/2.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "HomeMoreTable.h"

@interface HomeMoreTable()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)NSMutableArray *dataAr;
@end
@implementation HomeMoreTable
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _dataAr =[[NSMutableArray alloc]initWithObjects:@"当前任务",@"待接单",@"待处理",@"处理中",@"挂起中",@"待确认",@"历史任务", nil];
        self.delegate=self;
        self.dataSource=self;
        self.scrollEnabled=NO;
       self.alpha=0.9;
        self.separatorStyle=UITableViewCellSeparatorStyleNone;
        [self reloadData];

    }
    
    return self;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataAr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"cell"]; //出列可重用的cell

    //重用的cell
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        UILabel *line=[[UILabel alloc]initWithFrame:CGRectMake(10, 0, 50, 1)];
        line.tag=10;
        [cell.textLabel addSubview:line];
    }
    
    UILabel *line=[cell.contentView viewWithTag:10];
    if (indexPath.row==_dataAr.count-1) {
        line.backgroundColor=C(@"5f5e5e");
    }else
    {
        line.backgroundColor=[UIColor clearColor];
  
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    cell.backgroundColor=C(@"484848");
//    cell.alpha=0.8;
    cell.textLabel.text=[_dataAr objectAtIndex:indexPath.row];
    cell.textLabel.font=F(14);
    cell.textLabel.textColor=[UIColor whiteColor];
    cell.textLabel.frame=CGRectMake(0, 0, 100, 40);
    cell.textLabel.textAlignment=NSTextAlignmentCenter;
    
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
    if (self.CCellSelect) {
        NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
        [dic setObject:[_dataAr objectAtIndex:indexPath.row] forKey:@"type"];
        NSString * num=[NSString stringWithFormat:@"%d",indexPath.row];
        [dic setObject:num forKey:@"num"];
        self.CCellSelect(dic);
        }
}
@end
